package com.demo.aop;

import com.demo.aop.advisor.Advisor;
import com.demo.bean.BeanFactory;

import java.util.List;

public class DefaultAopProxyFactory implements AopProxyFactory {
    @Override
    public AopProxy createAopProxy(Object target, String beanName, List<Advisor> matchAdvisors, BeanFactory beanFactory) {
        if(isUseJdkAopProxy()){
            return new JDKAopProxy(this.getClass().getClassLoader(),target.getClass().getInterfaces(),matchAdvisors,target,beanFactory);
        }else{
            return new CglibAopProxy(this.getClass().getClassLoader(),target.getClass().getInterfaces(),matchAdvisors,target,beanName,beanFactory);
        }
    }

    private boolean isUseJdkAopProxy(){
        return false;
    }
}
